package com.globallogic.training.javase.easymock;

public class Lecture implements Comparable<Lecture> {

	private int numberInPlan;
	private Teacher teacher;
	private Group group;
	
	public Lecture(int numberInPlan, Teacher t, Group g) {
		this.teacher = t;
		this.group = g;
		this.numberInPlan = numberInPlan;
	}
	
	public int getNumber() {
		return numberInPlan;
	}
	
	public Teacher getTeacher() {
		return teacher;
	}

	public Group getGroup() {
		return group;
	}
	
	public String toString() {
		return "Lect" + super.toString();
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + getGroup().hashCode();
		result = prime * result + getTeacher().hashCode();
		result = result + ((numberInPlan < 0) ? 0 : numberInPlan);
		return result;
	}
	
	@Override
	public boolean equals(Object otherObject) {
		if (this == otherObject) {
			return true;
		}
		if (otherObject == null) {
			return false;
		}
		if (getClass() != otherObject.getClass()) {
			return false;
		}
		
		Lecture other = (Lecture) otherObject;
		if (this.getGroup().equals(other.getGroup())
				&& this.getTeacher().equals(other.getTeacher())
				&& this.getNumber() == other.getNumber()) {
			return true;
		}
		return false;
	}

	@Override
	public int compareTo(Lecture other) {
		int compare = numberInPlan - other.numberInPlan;
		if (compare > 0) {
			return 1;
		}
		if (compare < 0) {
			return -1;
		}
		return 0;
	}
	
}
